<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function (){
    $.get("loadBookType",function (data){
        $("[name='bookType']").empty();
        $("[name='bookType']").append("<option>--请选择--</option>")
        data.forEach(function (nameType){
            $("[name='bookType']").append("<option value='" + nameType.book_type + "'>" + nameType.book_type + "</option>");
        })
    })

    $.get("loadBorrwo",function (data){
        $("[name='isBorrwo']").empty();
        $("[name='isBorrwo']").append("<option>--请选择--</option>")
        data.forEach(function (nameType){
            $("[name='isBorrwo']").append("<option value='" + nameType.is_borrow + "'>" + nameType.is_borrow + "</option>");
        })
    })
    var book_type = $("[name='bookType']").val();
    var book_name = $("[name='bookName']").val();
    var is_borrwo = $("[name='isBorrwo']").val();
    $.get("show",{"book_type":book_type,"book_name":book_name,"is_borrwo":is_borrwo},function (data){
        $("[name='t']").empty();
        $("[name='t']").append("<tr>\n" +
            "            <td>图书编号</td>\n" +
            "            <td>图书分类</td>\n" +
            "            <td>图书名称</td>\n" +
            "            <td>作者</td>\n" +
            "            <td>出版社</td>\n" +
            "            <td>借阅</td>\n" +
            "        </tr>")
        data.forEach(function (nameType){
            $("[name='t']").append("<tr>" +
                "<td>"+nameType.book_code+"</td>" +
                "<td>"+nameType.book_type+"</td>" +
                "<td>"+nameType.book_name+"</td>" +
                "<td>"+nameType.book_author+"</td>" +
                "<td>"+nameType.publish_press+"</td>" +
                "<td>"+nameType.is_borrow+"</td>" +
                "</tr>")
        })
    })




})
</script>
    <h1>图书借阅系统</h1>
    <form action="show" name="myform">
        图书分类:<select name="bookType"></select>
        图书名称;<input type="text" name="bookName">
        是否借阅:<select name="isBorrwo"></select>
        <input type="submit" value="查询">
    </form>
    <span>当前用户<a th:text="${session.user.user_code}"></a></span>
    <table name="t">

    </table>
</body>
</html>